package com.mazsn.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mazsn.model.User;
import com.mazsn.service.UserService;

@RestController
public class UserController {

	@Autowired
	private UserService userService;
	
	@RequestMapping("/getUser")
	public User getUserByUserName() {
		String userName="bb2";
		return userService.findUserByUserName(userName);
	}
	
	@RequestMapping("/getUsers")
	public List<User> getUsers() {
		return userService.findAll(0, 10);
	}
	
	@RequestMapping("/addUser")
	public Integer addUser(){
		User user= new User();
		user.setEmail("ff@email.com");
		user.setNickName("ff1");
		user.setPassWord("ff#psd");
		user.setRegTime("2018-04-24 13:56:00");
		user.setUserName("ff");
		return userService.addUser(user);
	}
	
}
